import request from '@/utils/request'
import { dataTool } from 'echarts'
import { da } from 'element-plus/es/locale/index.mjs'
const baseUrl = '/cz-system/api/v1' //系统用户
// http://47.122.3.254:9999/cz-system/api/v1

/*
 角色:分页列表
# POST {{baseUrl}}/roles/page
# 过滤条件: 角色名称:name  角色状态:status (1-正常 0-停用)  公司Id:companyId 公司名称:companyName
# 创建时间时间区间: 开始:beginCreateTime 结束:endCreateTime
*/
export const getRolesPage = (data: any) => {
  return request({
    url: baseUrl + '/roles/page',
    method: 'POST',
    data:data
  })
}
// 角色可选所有菜单
export const getRoleMenuList = () => {
  return request({
    url: baseUrl + '/roles/platformRoleMenus',
    method: 'GET'
  })
}
// 查询所有所属公司列表
export const getCompanyList = (data: any = {}) => {
  return request({
    url: baseUrl + '/company/getSysCompanyList',
    method: 'POST',
    data:data
  })
}
// 角色:新增
export const addRole = (data: any) => {
  return request({
    url: baseUrl + '/roles',
    method: 'POST',
    data:data
  })
}
// 查询角色详情

//查询企业
export const getRoleDetail = (id: any) => {
  return request({
    url: baseUrl + '/roles/' + id,
    method: 'GET'
  })
}

//角色:分配菜单权限
export const UpdatePermissions = (array: Array<any>) => {
  return request({
    url: baseUrl + '/roles/' + array +'/menus',
    method: 'PUT'
  })
}
//角色 删除

export const deleteRole = (id: any) => {
  return request({
    url: baseUrl + '/roles/' + id,
    method: 'DELETE'
  })
}
//角色 状态 /roles/{roleId}/status?status=1
export const updateRoleStatus = (id: any, status: any) => {
  return request({
    url: baseUrl + '/roles/' + id + '/status?status=' + status,
    method: 'PUT'
  })
}
// 查询角色所有权限
export const getRolePermissions = (id: any) => {
  return request({
    url: baseUrl + '/roles/' + id + '/menuIds',
    method: 'GET'
  })
}
//查询单个角色详情
export const getRoleDetailById = (id: any) => {
  return request({
    url: baseUrl + '/roles/' + id,
    method: 'GET'
  })
}
// 更新角色权限
export const updateRolePermissions = (data: any) => {
  return request({
    url: baseUrl + '/roles',
    method: 'PUT',
    data:data
  })
}
